<div ng-controller="fullReductionEditCtrl">
    <div class="bg-light lter b-b wrapper-md ng-scope">
        <h4 class="m-n font-thin">增加满减送</h4>
        <button ui-sref="app.fullReduction" class="btn-back btn btn-dark btn-sm btn-rounded">
            返回
        </button>
    </div>

    <form name="activitiesForm" class="form-horizontal form-validation" ng-submit="editFullReduction()">
        <div class="wrapper-md">
            <div class="panel panel-body">
                <div class="m-b-sm">
                    <div>
                        <div class="padder-md padder-v bg-light m-b-sm">
                            <span class="font-bold">活动信息</span>
                        </div>
                    </div>
                    <div class="form-horizontal form-validation">
                        <div class="form-group">
                            <label class="col-sm-1 control-label">活动名称</label>

                            <div class="col-sm-4">
                                <input type="text" name="name" ng-model="fullReductionVO.name"
                                       class="form-control m-b-xs" placeholder="请输入商品名" required>

                                <div ng-if="activitiesForm.name.$touched">
                                    <p ng-if="activitiesForm.name.$error.required" class="text-danger h6">活动名称是必需的</p>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-1 control-label">生效时间</label>

                            <div class="col-sm-6 form-inline">
                                <div class="input-group" ng-controller="DatepickerDemoCtrl">
                                    <div class="input-group  no-padder m-n w-lg">
                                        <input type="text" class="form-control"
                                               placeholder="请输入开始日期"
                                               uib-datepicker-popup="yyyy-MM-dd"
                                               datepicker-popup="yyyy-MM-dd"
                                               ng-model="fullReductionVO.startTime"
                                               alt-input-formats="altInputFormats" is-open="opened"
                                               datepicker-options="dateOptions" close-text="关闭"
                                               clear-text="清空" min-date="minDate" max-date="fullReductionVO.endTime"
                                               current-text="今天" ng-change="queryForGoods()" disabled/>
                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-default"
                                                ng-click="open($event)" disabled>
                                            <i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                                    </div>
                                </div>
                                <div class="input-group" ng-controller="DatepickerDemoCtrl">
                                    <div class="input-group  no-padder m-n w-lg">
                                        <input type="text" class="form-control"
                                               placeholder="请输入结束日期"
                                               uib-datepicker-popup="yyyy-MM-dd"
                                               datepicker-popup="yyyy-MM-dd"
                                               ng-model="fullReductionVO.endTime"
                                               alt-input-formats="altInputFormats" is-open="opened"
                                               datepicker-options="dateOptions" close-text="关闭"
                                               clear-text="清空"
                                               current-text="今天" min-date="fullReductionVO.startTime"  ng-change="queryForGoods()" disabled/>
                                    <span class="input-group-btn ">
                                        <button type="button" class="btn btn-default"
                                                ng-click="open($event)" disabled>
                                            <i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="m-b-sm">
                    <div class="form-horizontal form-validation">
                        <div class="padder-md padder-v bg-light m-b-sm">
                            <span class="font-bold">优惠设置</span>
                        </div>
                        <div class="table-responsive b-a">
                            <table class="table table-striped b-light m-b-none">
                                <thead>
                                <tr>
                                    <th width="100">层级</th>
                                    <th>优惠门槛</th>
                                    <th>优惠方式(可多选)</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="item in fullReductionConditionJson track by $index">
                                    <td>
                                        {{item.level}}
                                    </td>
                                    <td>
                                        <div class="form form-inline">
                                            <label class="control-label m-r-xs">满</label>
                                            <input type="number" ng-model="item.aboveMoney"
                                                   class="input-sm form-control m-t-xs m-r-xs" name="aboveMoney"
                                                   placeholder="0.00" required>
                                            <label class="control-label">元</label>
                                        </div>
                                        <div ng-if="activitiesForm.aboveMoney.$touched" class="m-t">
                                            <p ng-if="activitiesForm.aboveMoney.$error.required" class="text-danger h6">优惠门槛是必须的</p>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="form-group m-r">
                                            <div>
                                                <label class="form form-inline">
                                                    <input class="form-group" type="checkbox"
                                                           ng-model="item.isOpenDecreaseCash"
                                                           ng-false-value="0" ng-true-value="1">

                                                    <div class="form-group"
                                                         ng-if="item.isOpenDecreaseCash==0"  ng-init="item.decreaseCash=0.00">
                                                        <span>减现金</span>
                                                    </div>
                                                    <div class="form-group"
                                                         ng-if="item.isOpenDecreaseCash==1">
                                                        <p class="inline m-r-xs">减</p>
                                                        <input type="number" name="decreaseCash" min="0.00"
                                                               class="inline w-xs form-control m-r-xs"
                                                               ng-model="item.decreaseCash"
                                                               placeholder="0.00">

                                                        <p class="inline m-n">元</p>
                                                    </div>
                                                </label>
                                            </div>
                                            <div>
                                                <label class="form form-inline">
                                                    <input class="form-group" type="checkbox"
                                                           ng-model="item.isOpenDiscount"
                                                           ng-false-value="0" ng-true-value="1">

                                                    <div class="form-group"
                                                         ng-if="item.isOpenDiscount==0" ng-init="item.discount=0.0">
                                                        <span>打折</span>
                                                    </div>
                                                    <div class="form-group"
                                                         ng-if="item.isOpenDiscount==1">
                                                        <p class="inline m-r-xs">打</p>
                                                        <input type="number" name="discount" min="0.1" step="0.1"
                                                               class="inline w-xs form-control m-r-xs"
                                                               ng-model="item.discount"
                                                               placeholder="0.0">

                                                        <p class="inline m-n">折</p>
                                                    </div>
                                                </label>
                                            </div>
                                            <div ng-if="item.level==1">
                                                <label class="form form-inline">
                                                    <input type="checkbox"
                                                           ng-model="item.isOpenPostageFree"
                                                           ng-false-value="0" ng-true-value="1"
                                                           class="form-group"><span>免邮（同一订单，若部分商品满足免邮，则该订单的所有商品都免邮）</span>
                                                </label>
                                            </div>
                                            <!--<div>-->
                                                <!--<label class="form form-inline">-->
                                                    <!--<input class="form-group" type="checkbox"-->
                                                           <!--ng-model="item.isOpenPoints"-->
                                                           <!--ng-false-value="0" ng-true-value="1">-->

                                                    <!--<div class="form-group"-->
                                                         <!--ng-if="item.isOpenPoints==0" ng-init="item.points=0">-->
                                                        <!--<span>送积分</span>-->
                                                    <!--</div>-->
                                                    <!--<div class="form-group"-->
                                                         <!--ng-if="item.isOpenPoints==1">-->
                                                        <!--<p class="inline m-r-xs">送</p>-->
                                                        <!--<input type="number" name="points" min="1"-->
                                                               <!--class="inline w-xs form-control m-r-xs"-->
                                                               <!--ng-model="item.points"-->
                                                               <!--placeholder="0">-->

                                                        <!--<p class="inline m-n">积分</p>-->
                                                    <!--</div>-->
                                                <!--</label>-->
                                            <!--</div>-->
                                            <div>
                                                <label class="form form-inline">
                                                    <input class="form-group" type="checkbox"
                                                           ng-model="item.isOpenCoupon"
                                                           ng-false-value="0" ng-true-value="1">
                                                    <div class="form-group"
                                                         ng-if="item.isOpenCoupon==0" ng-init="item.couponCount=0">
                                                        <span>送优惠</span>
                                                    </div>
                                                    <div class="form-group"
                                                         ng-if="item.isOpenCoupon==1">
                                                        <p class="inline m-r-xs">送</p>
                                                        <select class="input-sm form-control" ng-model="item.couponId"
                                                                ng-options="coupons.id as coupons.name for coupons in couponsList">
                                                        </select>
                                                        <!--<input type="number" name="coupon" min="1"-->
                                                               <!--class="inline w-xs form-control m-r-xs"-->
                                                               <!--ng-model="item.couponCount"-->
                                                               <!--placeholder="0">-->

                                                        <!--<p class="inline m-n">张</p>-->
                                                    </div>
                                                </label>
                                            </div>
                                        </div>
                                    </td>
                                    <td><a ng-if="item.level!=1" ng-click="popCondition(item.level)">删除</a></td>
                                </tr>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="4">
                                        <button class="btn btn-default btn-sm m-r-xs" ng-click="pushCondition()"><i
                                                class="glyphicon glyphicon-plus"></i>新增一级优惠
                                        </button>
                                        <span class="inline h6 m-t-sm">最多可设置五个层级 (每级优惠不累加)</span>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>

                <div class="m-b-sm">
                    <div class="padder-md padder-v bg-light m-b-sm">
                        <span class="font-bold">选择活动商品</span>
                    </div>
                    <div class="form-horizontal form-validation">
                        <div class="form-group">
                            <label class="col-sm-1 control-label">活动商品:</label>

                            <div class="col-sm-4">
                                <div class="m-b-sm">
                                    <div class="m-b-sm">
                                        <div class="radio inline">
                                            <label class="i-checks i-checks-sm">
                                                <input type="radio" name="activitiesType"
                                                       ng-model="fullReductionVO.type" value="0" required
                                                       ng-click="changeActivitiesType(0)"
                                                       class="ng-pristine ng-untouched ng-valid ng-valid-required">
                                                <i></i>
                                            </label>
                                        </div>
                                        <p class="inline m-n">所有商品参加
                                            <i class="m-l-xs fa fa-question-circle text-muted pos-rlt h6" popover-placement="right"
                                               popover="所有商品是指当前活动时间内所有符合参与条件的商品" popover-trigger="mouseenter"></i>
                                        </p>
                                    </div>
                                </div>
                                <div class="m-b-sm">
                                    <div class="m-b-sm">
                                        <div class="radio inline">
                                            <label class="i-checks i-checks-sm">
                                                <input type="radio" name="activitiesType"
                                                       ng-model="fullReductionVO.type" value="1" required
                                                       ng-click="changeActivitiesType(1)"
                                                       class="ng-pristine ng-untouched ng-valid ng-valid-required">
                                                <i></i>
                                            </label>
                                        </div>
                                        <p class="inline m-n">部分商品参加
                                            <span ng-if="fullReductionVO.type==0">0</span>
                                            <span ng-if="fullReductionVO.type==1">{{fullReductionGoodsVO.goodsIdArr.length}}</span>
                                            个</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="wrapper b-t text-center">
                    <button class="btn btn-default" ui-sref="app.fullReduction">取消</button>
                    <button type="submit" class="btn btn-info" ng-if="!saveStatus">保存</button>
                    <button class="btn btn-info" ng-if="saveStatus" disabled><i class="fa fa-spin fa-refresh m-r-xs"></i>保存中..</button>
                </div>
            </div>
        </div>
    </form>
</div>